Skip to content

Conversation

@rachelmcr
Copy link
Contributor

@rachelmcr rachelmcr commented May 30, 2023

Closes: #9837

Description

This PR increases the app's resilience when Product fields have unexpected types:

  • When a product's SKU is a number instead of a String.
  • When a product's weight is a number instead of a String.
  • When a product dimensions (length, width, height) are a number instead of a String.
  • When a product download's ID is a number instead of a String.

It uses failsafe decoding to handle those alternative types, and adds to the unit test for parsing alternative types in a Product. (These are known decoding errors that users have experienced.)

Testing instructions

We don't know the exact plugins that can cause this behavior, but you can test using a tool like Charles Proxy or Proxyman to intercept and modify the response:

  1. Set a breakpoint in your tool of choice for requests to the /wc/v3/products endpoint.
  2. Build and run the app.
  3. Open the Products tab.
  4. Modify the response in one or more of the following ways:
    • A product's SKU is a number (e.g. "sku": 123 or see the product-alternative-types.json mock for an example).
    • A product's weight is a number (e.g. "weight": 213).
    • A product's dimensions is a number (e.g. "dimensions": { "length": 12, "width": 33, "height": 54 }).
    • A product's download ID is a number (e.g. "downloads": [{ "id" : 12345, "name" : "Song #1", "file" : "https://example.com/woo-single-1.ogg" }]).
  5. Execute the response and confirm the app loads the product list.

Screenshots

Before After
Simulator Screen Shot - iPhone 14 Pro - 2023-05-30 at 16 09 25 Simulator Screen Shot - iPhone 14 Pro - 2023-05-30 at 16 12 43

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@rachelmcr rachelmcr added feature: product list Related to the product list. category: reliability Related to app’s reliability, accuracy, and perceived waiting time labels May 30, 2023
@rachelmcr rachelmcr added this to the 13.9 milestone May 30, 2023
@rachelmcr rachelmcr marked this pull request as ready for review May 30, 2023 15:18
@rachelmcr rachelmcr requested review from Ecarrion and ThomazFB May 30, 2023 15:18
@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr9846-87a9b00 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@rachelmcr rachelmcr merged commit 892858e into trunk May 31, 2023
@rachelmcr rachelmcr deleted the issue/9837-product-decoding-fallbacks branch May 31, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: reliability Related to app’s reliability, accuracy, and perceived waiting time feature: product list Related to the product list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reliability] Add fallbacks for known Product decoding errors

4 participants